


clear all
set more off

use "$data\applications_individual-level.dta" , clear

drop *dl
rename prv_la prov 
replace prov=utg if missing(prov)
rename reg_la region
replace region=utg_reg if missing(region)

rename cit_la nationality 
replace nationality=nas_la if missing(nationality)
rename nas_la cb
replace cb=nationality if missing(cb)

rename sesso_la gender
gen male=gender==1
rename stci_la ms 

gen age=2002-dnas_la
sum age, d
gen age2=age^2
keep if age>=18&age<=60
gen agec = .
replace agec= 1 if age<=24
replace agec= 2 if age>=25&age<=29
replace agec= 3 if age>=30&age<=34
replace agec= 4 if age>=35&age<=39
replace agec= 5 if age>=40&age<=44
replace agec= 6 if age>=45&age<=60
tab agec
lab define agecl 1 "less 24" 2 "25-29" 3 "30-34" 4 "35-39" 5 "40-44" 6 "45-60"
lab values agec agecl

rename clretri wagec
tab wagec
gen wage =.
replace wage = 99 if wagec==0
replace wage = 150 if wagec==1
replace wage = 250 if wagec==2
replace wage = 350 if wagec==3
replace wage = 450 if wagec==4
replace wage = 550 if wagec==5
replace wage = 650 if wagec==6
replace wage = 750 if wagec==7
replace wage = 850 if wagec==8
replace wage = 950 if wagec==9
replace wage = 1100 if wagec==10
replace wage = 1350 if wagec==11
replace wage = 1750 if wagec==12
replace wage = 3000 if wagec==13
replace wage = 4001 if wagec==14

codebook ms
keep if missing(prov)==0&missing(cb)==0&missing(gender)==0
gen irregulars=1

gen Married = .
replace Married=1 if (ms=="C" | ms=="V") 
replace Married=0 if ms=="L"

gen area= .
replace area=1 if region<=8
replace area=2 if region>=9 & region<=12
replace area=3 if region>=13
tab area, gen(da)
rename da1 North
rename da2 Center
rename da3 South 

gen eg=.
replace eg=1 if cb==203 | cb==206 | cb==212 | cb==214 | cb==216 | cb==221 | cb==226 | cb==232 | cb==219 | cb==240 | cb==215 | cb==220 | cb==234 | cb==239 // eu15 
replace eg=2 if cb==257 | cb==315 | cb==247 | cb==248 | cb==249 | cb==227 | cb==233 | cb==255 | cb==251 | cb==244 
replace eg=3 if cb==209 | cb==235 // eu2007
replace eg=4 if cb==224 | cb==250 | cb==201 | cb==252 | cb==223 | cb==272 | cb==253 | cb==270 | cb==271 | cb==351 | cb==202 | cb==256 | cb==925 | cb==225 | cb==959 | cb==254 | cb==229 | cb==231 | cb==245 | cb==236 | cb==246 | cb==243 // euother
replace eg=5 if cb>=401 & cb<=467 // africa
replace eg=6 if (cb>=301 & cb<=314) | (cb>=316 & cb<=350) | (cb>=352 & cb<=364) | cb==703 | cb==708 | cb==712 | cb==713 | cb==715 | cb==720 | cb==721 | cb==725 | cb==727 | cb==730 | cb==731 | cb==732 // asia e
replace eg=7 if cb==503 | cb==505 | cb==506 | cb==507 | cb==513 | cb==514 | cb==515 | cb==516 | cb==517 | cb==518 | cb==519 | cb==523 | cb==524 | cb==525 | cb==527 | cb==529 | cb==530 | cb==532 | cb==533 | cb==534 | cb==602 | cb==604 | cb==605 | cb==606 | cb==608 | cb==609 | cb==612 | cb==614 | cb==615 | cb==616 | cb==617 | cb==618 | cb==619 // america s
replace eg=8 if cb==509 | cb==536 | cb==241 | cb==701 | cb==326 | cb==319 | cb==719  // oecd
lab define egl 1 "EU15" 2 "EU2004" 3 "EU2007" 4 "EU_Other" 5 "Africa" 6 "Asia" 7 "South America" 8 "OECD"
lab values eg egl

tab eg, gen(egg)
rename egg1 EU15
rename egg2 EU2004
rename egg3 EU2007
rename egg4 EU_Other
rename egg5 Africa
rename egg6 Asia
rename egg7 South_America
rename egg8 OECD


********************************************************************************
*  Appendix Table A9: Males and Females
*  Characteristics of applicants to the generalized amnesty of 2002

gl cov age Married  EU15 EU2004 EU2007 EU_Other Africa Asia South_America OECD North Center South
tabstat $cov , by(male) stat(mean sd min max p50) format(%9.2f)

